Document the feature
authorKarol Kuczmarski <karol.kuczmarski@gmail.com>
Sat, 13 May 2017 16:00:52 +0000 (17:00 +0100)
committerKarol Kuczmarski <karol.kuczmarski@gmail.com>
Sat, 13 May 2017 16:00:52 +0000 (17:00 +0100)
src/doc/build-script.md

index 586dd29f056b6969aa8f1cd6b9d45a86e7fc058e..b747ed0c0953a1edd5552b41b480dbf9112d05ab 100644 (file)
@@ -51,6 +51,7 @@ All the lines printed to stdout by a build script are written to a file like `ta
 cargo:rustc-link-lib=static=foo
 cargo:rustc-link-search=native=/path/to/foo
 cargo:rustc-cfg=foo
+cargo:rustc-env=FOO=bar
 # arbitrary user-defined metadata
 cargo:root=/path/to/foo
 cargo:libdir=/path/to/foo/lib
@@ -73,6 +74,12 @@ crate is built:
 * `rustc-cfg=FEATURE` indicates that the specified feature will be passed as a
   `--cfg` flag to the compiler. This is often useful for performing compile-time
   detection of various features.
+* `rustc-env=VAR=VALUE` indicates that the specified environment variable
+  will be added to the environment which the compiler is run within.
+  The value can be then retrieved by the `env!` macro in the compiled crate.
+  This is useful for embedding additional metadata in crate's code,
+  such as the hash of Git HEAD or the unique identifier of a continuous
+  integration server.
 * `rerun-if-changed=PATH` is a path to a file or directory which indicates that
   the build script should be re-run if it changes (detected by a more-recent
   last-modified timestamp on the file). Normally build scripts are re-run if